<?php
/**
 * Smart Library - Smart Framework
 * http://smart-framework.highet.eu
 *
 * @category   SmartL
 * @package    SmartL_DataBinder
 * @subpackage BindingRules
 * @copyright  Copyright (c) 2005-2008 Smart Framework team - Stepan Sindelar, Vojtech Vit
 * @license    http://www.opensource.org/licenses/bsd-license.php	New BSD License
 */

/**
 * Messenger for binding rule that can't be written an index and its value in array.
 * 
 * Binding rules can be written in array as 
 * an index - rule for field of first object and value - rule for field of second object
 * or as instance of this class. 
 *
 * @package SmartL_DataBinder
 * @subpackage BindingRules
 */
class SmartL_DataBinder_BindingRule {
	/**
	 * Stored binding rule.
	 *
	 * @var array[numeric]=>array
	 */
	private $_fields;
	
	/**
	 * Constructs binding rule.
	 *
	 * @param array $field1 Rule for field from first object.
	 * @param array $field2 Rule for field from second object.
	 */
	public function __construct($field1, $field2) {
		$this->_fields [0] = $field1;
		$this->_fields [1] = $field2;
	}
	
	public function getField1Rule() {
		return $this->_fields [0];
	}
	public function getField2Rule() {
		return $this->_fields [1];
	}
	
	public function switchRule() {
		$pom = $this->_fields [0];
		$this->_fields [0] = $this->_fields [1];
		$this->_fields [1] = $pom;
	}
}
